package com.dmy.chat.server.netty;

import com.dmy.chat.server.netty.message.Messages;
import io.netty.channel.Channel;
import io.netty.channel.ChannelId;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

import java.util.Map;

/**
 * create by YCQ for 2020/1/13 10:45
 */
public class ChatServerChannelManager extends ChannelManager<Messages> {

    @Override
    public void sendByChannnelId(ChannelId channelId, Messages msg) {
        Channel channel = CHANNELS.find(channelId);
        channel.writeAndFlush(new TextWebSocketFrame(msg.getContent())) ;
    }

    @Override
    public void sendAll(Messages msg) {
            CHANNELS.writeAndFlush(new TextWebSocketFrame(msg.getContent())) ;
    }
}
